package io.jt808.proto.req;

import io.norland.buffer.AutoBuffer;
import io.norland.annotations.Proto;
import io.norland.proto.IProto;
import lombok.Data;

/**
 * 位置信息查询应答
 */
@Proto("0201")
@Data
public class JT0201 implements IProto {
    /**
     * 对应的位置信息查询消息的流水号
     */

    private short responseMessageSerialNo;


    /**
     * 位置信息汇报
     */
    private JT0200 positionReport;


    public final byte[] writeToBytes() {
        AutoBuffer buff = new AutoBuffer();
        buff.writeShort(responseMessageSerialNo);
        buff.writeBytes(positionReport.writeToBytes());
        return buff.array();

    }

    public final void readFromBuf(AutoBuffer buff) {
        responseMessageSerialNo = buff.readShort();
        positionReport = new JT0200();
        positionReport.readFromBuf(buff.slice(buff.readerIndex(), buff.readableBytes()));

    }
}